package com.ctshk.rpc.starvip.factory.member;

import com.ctshk.rpc.starvip.dto.start_vip.member.ListOfMembers;
import com.ctshk.rpc.starvip.dto.start_vip.member.Member;
import com.ctshk.rpc.starvip.dto.start_vip.member.MemberOperation;
import com.ctshk.rpc.starvip.dto.start_vip.member.register.*;
import com.ctshk.rpc.starvip.dto.start_vip.user.ContactOrganization;
import com.ctshk.rpc.starvip.dto.start_vip.user.ListOfContactOrganization;
import com.ctshk.rpc.starvip.dto.start_vip.user.ListOfLoyMemberOrganization;
import com.ctshk.rpc.starvip.dto.start_vip.user.LoyMemberOrganization;
import com.ctshk.rpc.starvip.factory.StarVipReqProvider;
import com.ctshk.rpc.starvip.req.member.MemberChangePasswordReq;
import com.ctshk.rpc.starvip.req.member.MemberRegisterReq;
import com.google.common.collect.Lists;

import java.time.LocalDateTime;

/**
 * @BelongsProject: ctshk-cloud
 * @BelongsPackage: com.ctshk.rpc.starvip.factory.member
 * @Author: hef
 * @CreateTime: 2021-04-12 19:55
 * @Description: 注册个人会员
 */
public class MemberRegisterFactory extends StarVipReqProvider<MemberRegisterReq> {
    public MemberRegisterFactory(MemberRegisterReq req) {
        super(req);
    }

    @Override
    public RegisterMemberOperation produce() {
        RegisterMemberOperation memberOperation = new RegisterMemberOperation();
        memberOperation.setListOfMembers(new RegisterListOfMembers(
                Lists.newArrayList(
                        new RegisterMember()
                                .setEnrollmentChannel(req.getEnrollmentChannel())
                                .setCtsLogin(req.getCtsLogin())
                                .setCtsPassword(req.getCtsPassword())
                                .setCtsIgnoreMobile("N")
                                .setCtsIgnoreEmail("N")
                                .setListOfContact(new RegisterListOfContact(
                                        Lists.newArrayList(
                                                new RegisterContact()
                                                        .setMf(req.getMf())
                                                        .setCtsFstName(req.getCtsFstName())
                                                        .setCtsLastName(req.getCtsLastName())
                                                        .setCellularPhone(req.getCellularPhone())
                                                        .setEmailAddress(req.getEmailAddress())
                                                        .setListOfContactOrganization(new ListOfContactOrganization(
                                                                Lists.newArrayList(new ContactOrganization()
                                                                        .setOrganizationNum(req.getCtsCompanyNumber())
                                                                )
                                                        )
                                        ))
                                ))
                                .setListOfLOYMemberOrganization(new ListOfLoyMemberOrganization(
                                        Lists.newArrayList(new LoyMemberOrganization().setOrganizationNum(req.getCtsCompanyNumber()))
                                ))
                                .setListOfLoyMembershipCard(new RegisterListOfLoyMembershipCard(
                                Lists.newArrayList(
                                        new RegisterLoyMembershipCard()
                                        .setCtsCompanyNumber(req.getCtsCompanyNumber())
                                        .setCtsCardSegment(req.getCtsCardSegment())
                                        .setActiveFlag(req.getActiveFlag())
                                        .setCtsCardNumber(req.getCtsCardNumber())
                                        .setCardStatusCode(req.getCardStatusCode())
                                        .setCardType(req.getCardType())
                                        .setExpirationDateOnCard(req.getExpirationDateOnCard())
                                        .setStartDate(req.getStartDate())
                                )))
                )
        ));
        memberOperation.setMessageId("1-KFKL");
        memberOperation.setIntObjectName("LOY Member");
        memberOperation.setInterfaceId("CTS_IF_07");
        memberOperation.setOperation("Insert");
        memberOperation.setMessageType("Integration Object");
        memberOperation.setIntObjectFormat("Siebel Hierarchical");
        return memberOperation;
    }
}
